/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.editparts;

import java.beans.PropertyChangeEvent;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.PolylineDecoration;
import org.eclipse.draw2d.RotatableDecoration;

import edu.pku.sei.modeler.edit.parts.AbstractLinkEditPart;
import edu.pku.sei.modeler.model.structure.MetaShapeElement;

/**
 * @deprecated
 * @author zl
 *
 */
public class TemplateConnEditPart extends AbstractLinkEditPart {
private RotatableDecoration targetDecor;
	
	public TemplateConnEditPart(MetaShapeElement model) {
		super(model);
	}
	
	protected void createEditPolicies() {
		super.createEditPolicies();
	}
	protected IFigure createFigure() {
		PolylineConnection conn = new PolylineConnection();	
		return conn;
	}
	
	public PolylineConnection getConnection() {
		return (PolylineConnection)getFigure();
	}
	
	private PolylineDecoration createPolylineDecoration() {
		PolylineDecoration decoration = new PolylineDecoration();
		decoration.setScale(10, 5);
		return decoration;
	}
	protected void handlePropertyChanged(PropertyChangeEvent event) {
		
	}
	protected void refreshVisuals() {
		super.refreshVisuals();
		updateTargetDecoration();
	}
	
	private void updateTargetDecoration() {
		if(!getLink().isHard()) {
			if (targetDecor == null) {
				targetDecor = createPolylineDecoration();
			}
			getConnection().setTargetDecoration(targetDecor);
		}
	}
}
